package edu.hitsz.aircraft;

import edu.hitsz.StartGame;
import edu.hitsz.aircraft.AbstractAircraft;
import edu.hitsz.application.Game;
import edu.hitsz.application.Main;
import edu.hitsz.application.MusicThread;
import edu.hitsz.bullet.AbstractBullet;
import edu.hitsz.observerpattern.Subscriber;
import edu.hitsz.prop.AbstractProp;
import edu.hitsz.propfactory.BloodFactory;
import edu.hitsz.propfactory.BombFactory;
import edu.hitsz.propfactory.BulletFactory;

import java.util.List;
import java.util.Random;

public abstract class AbstractEnemy extends AbstractAircraft implements Subscriber {

    public AbstractEnemy(int locationX, int locationY, int speedX, int speedY,int hp,int shootNum,int power,int direction) {
        super(locationX, locationY, speedX, speedY, hp);
        this.shootNum = shootNum;
        this.power = power;
        this.direction = direction;
    }

    public AbstractEnemy(int locationX, int locationY, int speedX, int speedY,int hp) {
        super(locationX, locationY, speedX, speedY, hp);
    }

    @Override
    public List<AbstractBullet> shoot() {
        return null;
    }

    public AbstractProp drop() {
        Random r = new Random();
        int proptype = r.nextInt(3);
        if (proptype == 0) {
            return  new BloodFactory().createProp(this);
        } else if (proptype == 1) {
            return new BombFactory().createProp(this);
        } else {
            return new BulletFactory().createProp(this);
        }
    }

    @Override
    public void update() {
        this.vanish();
        Game.score += 10;
        if(StartGame.isPlay) {
            new MusicThread(MusicThread.bombExplosion).start();
        }
    }
}
